{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"http://hilpisch.com/tpq_logo.png\" alt=\"The Python Quants\" width=\"35%\" align=\"right\" border=\"0\"><br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python for Finance"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Analyze Big Financial Data**\n",
    "\n",
    "O'Reilly (2014)\n",
    "\n",
    "Yves Hilpisch"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img style=\"border:0px solid grey;\" src=\"http://hilpisch.com/python_for_finance.png\" alt=\"Python for Finance\" width=\"30%\" align=\"left\" border=\"0\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Buy the book ** |\n",
    "<a href='http://shop.oreilly.com/product/0636920032441.do' target='_blank'>O'Reilly</a> |\n",
    "<a href='http://www.amazon.com/Yves-Hilpisch/e/B00JCYHHJM' target='_blank'>Amazon</a>\n",
    "\n",
    "**All book codes & IPYNBs** |\n",
    "<a href=\"http://oreilly.quant-platform.com\">http://oreilly.quant-platform.com</a>\n",
    "\n",
    "**The Python Quants GmbH** | <a href='http://pythonquants.com' target='_blank'>www.pythonquants.com</a>\n",
    "\n",
    "**Contact us** | <a href='mailto:analytics@pythonquants.com'>analytics@pythonquants.com</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Volatility Options"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The VSTOXX Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('../python')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "uuid": "9d8e35b5-239f-4b3c-85dd-f7807b6fb39d"
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### VSTOXX Index Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "uuid": "bec1849e-b622-463c-a559-bd3a6ab82824"
   },
   "outputs": [],
   "source": [
    "url = 'http://www.stoxx.com/download/historical_values/h_vstoxx.txt'\n",
    "vstoxx_index = pd.read_csv(url, index_col=0, header=2,\n",
    "                           parse_dates=True, dayfirst=True,\n",
    "                           sep=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "uuid": "e895e580-70dd-46b0-bcd1-9e686e226520"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 4226 entries, 1999-01-04 to 2015-08-07\n",
      "Data columns (total 9 columns):\n",
      "V2TX    4226 non-null float64\n",
      "V6I1    3787 non-null float64\n",
      "V6I2    4226 non-null float64\n",
      "V6I3    4169 non-null float64\n",
      "V6I4    4226 non-null float64\n",
      "V6I5    4226 non-null float64\n",
      "V6I6    4210 non-null float64\n",
      "V6I7    4226 non-null float64\n",
      "V6I8    4213 non-null float64\n",
      "dtypes: float64(9)\n",
      "memory usage: 330.2 KB\n"
     ]
    }
   ],
   "source": [
    "vstoxx_index.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "uuid": "2d7b9982-0f4a-4af9-abd0-af23ca157775"
   },
   "outputs": [],
   "source": [
    "vstoxx_index = vstoxx_index[('2013/12/31' < vstoxx_index.index)\n",
    "                            & (vstoxx_index.index < '2014/4/1')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "uuid": "189bc6a0-af48-4e05-afaa-ddb78d44b0ae"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>V2TX</th>\n",
       "      <th>V6I1</th>\n",
       "      <th>V6I2</th>\n",
       "      <th>V6I3</th>\n",
       "      <th>V6I4</th>\n",
       "      <th>V6I5</th>\n",
       "      <th>V6I6</th>\n",
       "      <th>V6I7</th>\n",
       "      <th>V6I8</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2014-03-25</th>\n",
       "      <td>18.26</td>\n",
       "      <td>18.23</td>\n",
       "      <td>18.31</td>\n",
       "      <td>19.04</td>\n",
       "      <td>19.84</td>\n",
       "      <td>20.31</td>\n",
       "      <td>18.11</td>\n",
       "      <td>20.83</td>\n",
       "      <td>21.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-03-26</th>\n",
       "      <td>17.59</td>\n",
       "      <td>17.48</td>\n",
       "      <td>17.70</td>\n",
       "      <td>18.45</td>\n",
       "      <td>19.42</td>\n",
       "      <td>20.00</td>\n",
       "      <td>20.26</td>\n",
       "      <td>20.45</td>\n",
       "      <td>20.86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-03-27</th>\n",
       "      <td>17.64</td>\n",
       "      <td>17.50</td>\n",
       "      <td>17.76</td>\n",
       "      <td>18.62</td>\n",
       "      <td>19.49</td>\n",
       "      <td>20.05</td>\n",
       "      <td>20.11</td>\n",
       "      <td>20.49</td>\n",
       "      <td>20.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-03-28</th>\n",
       "      <td>17.03</td>\n",
       "      <td>16.68</td>\n",
       "      <td>17.29</td>\n",
       "      <td>18.33</td>\n",
       "      <td>19.30</td>\n",
       "      <td>19.83</td>\n",
       "      <td>20.14</td>\n",
       "      <td>20.38</td>\n",
       "      <td>20.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-03-31</th>\n",
       "      <td>17.66</td>\n",
       "      <td>17.61</td>\n",
       "      <td>17.69</td>\n",
       "      <td>18.57</td>\n",
       "      <td>19.43</td>\n",
       "      <td>20.04</td>\n",
       "      <td>19.98</td>\n",
       "      <td>20.44</td>\n",
       "      <td>20.90</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             V2TX   V6I1   V6I2   V6I3   V6I4   V6I5   V6I6   V6I7   V6I8\n",
       "Date                                                                     \n",
       "2014-03-25  18.26  18.23  18.31  19.04  19.84  20.31  18.11  20.83  21.20\n",
       "2014-03-26  17.59  17.48  17.70  18.45  19.42  20.00  20.26  20.45  20.86\n",
       "2014-03-27  17.64  17.50  17.76  18.62  19.49  20.05  20.11  20.49  20.94\n",
       "2014-03-28  17.03  16.68  17.29  18.33  19.30  19.83  20.14  20.38  20.82\n",
       "2014-03-31  17.66  17.61  17.69  18.57  19.43  20.04  19.98  20.44  20.90"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.round(vstoxx_index.tail(), 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### VSTOXX Futures Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "uuid": "f55aa47f-15d5-4bfb-858c-3464101550c2"
   },
   "outputs": [],
   "source": [
    "vstoxx_futures = pd.read_excel('./source/vstoxx_march_2014.xlsx',\n",
    "                               'vstoxx_futures')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "uuid": "b03426df-f692-4879-8136-e3adc53a7c73"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 504 entries, 0 to 503\n",
      "Data columns (total 8 columns):\n",
      "A_DATE                       504 non-null datetime64[ns]\n",
      "A_EXP_YEAR                   504 non-null int64\n",
      "A_EXP_MONTH                  504 non-null int64\n",
      "A_CALL_PUT_FLAG              504 non-null object\n",
      "A_EXERCISE_PRICE             504 non-null int64\n",
      "A_SETTLEMENT_PRICE_SCALED    504 non-null int64\n",
      "A_PRODUCT_ID                 504 non-null object\n",
      "SETTLE                       504 non-null float64\n",
      "dtypes: datetime64[ns](1), float64(1), int64(4), object(2)\n",
      "memory usage: 35.4+ KB\n"
     ]
    }
   ],
   "source": [
    "vstoxx_futures.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "uuid": "cb69ca05-6568-4742-8a15-1355eb25ab2a"
   },
   "outputs": [],
   "source": [
    "del vstoxx_futures['A_SETTLEMENT_PRICE_SCALED']\n",
    "del vstoxx_futures['A_CALL_PUT_FLAG']\n",
    "del vstoxx_futures['A_EXERCISE_PRICE']\n",
    "del vstoxx_futures['A_PRODUCT_ID']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "uuid": "3b0a398d-b9d0-4826-8a32-65259768396a"
   },
   "outputs": [],
   "source": [
    "columns = ['DATE', 'EXP_YEAR', 'EXP_MONTH', 'PRICE']\n",
    "vstoxx_futures.columns = columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "uuid": "f82ad34e-431b-4827-971c-cb768e4d3632"
   },
   "outputs": [],
   "source": [
    "import datetime as dt\n",
    "import calendar\n",
    "\n",
    "def third_friday(date):\n",
    "    day = 21 - (calendar.weekday(date.year, date.month, 1) + 2) % 7\n",
    "    return dt.datetime(date.year, date.month, day)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "uuid": "2715995a-3122-472c-9b6b-8c425e3eac10"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set(vstoxx_futures['EXP_MONTH'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false,
    "uuid": "7b62171f-6817-4fcb-9976-1d0fc7731375"
   },
   "outputs": [],
   "source": [
    "third_fridays = {}\n",
    "for month in set(vstoxx_futures['EXP_MONTH']):\n",
    "    third_fridays[month] = third_friday(dt.datetime(2014, month, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false,
    "uuid": "0363243b-5218-45f5-9d92-263d13550a86"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: datetime.datetime(2014, 1, 17, 0, 0),\n",
       " 2: datetime.datetime(2014, 2, 21, 0, 0),\n",
       " 3: datetime.datetime(2014, 3, 21, 0, 0),\n",
       " 4: datetime.datetime(2014, 4, 18, 0, 0),\n",
       " 5: datetime.datetime(2014, 5, 16, 0, 0),\n",
       " 6: datetime.datetime(2014, 6, 20, 0, 0),\n",
       " 7: datetime.datetime(2014, 7, 18, 0, 0),\n",
       " 8: datetime.datetime(2014, 8, 15, 0, 0),\n",
       " 9: datetime.datetime(2014, 9, 19, 0, 0),\n",
       " 10: datetime.datetime(2014, 10, 17, 0, 0),\n",
       " 11: datetime.datetime(2014, 11, 21, 0, 0)}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "third_fridays"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "uuid": "55c35e4b-359d-49b5-a002-e5dfb4c89bae"
   },
   "outputs": [],
   "source": [
    "tf = lambda x: third_fridays[x]\n",
    "vstoxx_futures['MATURITY'] = vstoxx_futures['EXP_MONTH'].apply(tf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false,
    "uuid": "861ce5e7-6a8a-4ad0-998a-4f998b3f1abe"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DATE</th>\n",
       "      <th>EXP_YEAR</th>\n",
       "      <th>EXP_MONTH</th>\n",
       "      <th>PRICE</th>\n",
       "      <th>MATURITY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>7</td>\n",
       "      <td>20.40</td>\n",
       "      <td>2014-07-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>500</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>8</td>\n",
       "      <td>20.70</td>\n",
       "      <td>2014-08-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>501</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>9</td>\n",
       "      <td>20.95</td>\n",
       "      <td>2014-09-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>502</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>21.05</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>503</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>11</td>\n",
       "      <td>21.25</td>\n",
       "      <td>2014-11-21</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          DATE  EXP_YEAR  EXP_MONTH  PRICE   MATURITY\n",
       "499 2014-03-31      2014          7  20.40 2014-07-18\n",
       "500 2014-03-31      2014          8  20.70 2014-08-15\n",
       "501 2014-03-31      2014          9  20.95 2014-09-19\n",
       "502 2014-03-31      2014         10  21.05 2014-10-17\n",
       "503 2014-03-31      2014         11  21.25 2014-11-21"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vstoxx_futures.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### VSTOXX Options Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false,
    "uuid": "e57c3899-e4f4-41d4-8caf-a48a33cf5f1d"
   },
   "outputs": [],
   "source": [
    "vstoxx_options = pd.read_excel('./source/vstoxx_march_2014.xlsx',\n",
    "                               'vstoxx_options')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false,
    "uuid": "530e2488-d694-4bf9-8a36-925dda5a1169"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 46960 entries, 0 to 46959\n",
      "Data columns (total 8 columns):\n",
      "A_DATE                       46960 non-null datetime64[ns]\n",
      "A_EXP_YEAR                   46960 non-null int64\n",
      "A_EXP_MONTH                  46960 non-null int64\n",
      "A_CALL_PUT_FLAG              46960 non-null object\n",
      "A_EXERCISE_PRICE             46960 non-null int64\n",
      "A_SETTLEMENT_PRICE_SCALED    46960 non-null int64\n",
      "A_PRODUCT_ID                 46960 non-null object\n",
      "SETTLE                       46960 non-null float64\n",
      "dtypes: datetime64[ns](1), float64(1), int64(4), object(2)\n",
      "memory usage: 3.2+ MB\n"
     ]
    }
   ],
   "source": [
    "vstoxx_options.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false,
    "uuid": "d327407e-5645-4850-9296-8ed2a42a9f02"
   },
   "outputs": [],
   "source": [
    "del vstoxx_options['A_SETTLEMENT_PRICE_SCALED']\n",
    "del vstoxx_options['A_PRODUCT_ID']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false,
    "uuid": "aa1b23d5-3f09-4059-a5c1-c5c3d7b5619e"
   },
   "outputs": [],
   "source": [
    "columns = ['DATE', 'EXP_YEAR', 'EXP_MONTH', 'TYPE', 'STRIKE', 'PRICE']\n",
    "vstoxx_options.columns = columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false,
    "uuid": "9c503624-0ad5-43d4-aa05-bef9123b65cd"
   },
   "outputs": [],
   "source": [
    "vstoxx_options['MATURITY'] = vstoxx_options['EXP_MONTH'].apply(tf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false,
    "uuid": "2f07b024-89ff-40d2-b99a-23715299fdb5"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DATE</th>\n",
       "      <th>EXP_YEAR</th>\n",
       "      <th>EXP_MONTH</th>\n",
       "      <th>TYPE</th>\n",
       "      <th>STRIKE</th>\n",
       "      <th>PRICE</th>\n",
       "      <th>MATURITY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014-01-02</td>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "      <td>1000</td>\n",
       "      <td>7.95</td>\n",
       "      <td>2014-01-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2014-01-02</td>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "      <td>1500</td>\n",
       "      <td>3.05</td>\n",
       "      <td>2014-01-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2014-01-02</td>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "      <td>1600</td>\n",
       "      <td>2.20</td>\n",
       "      <td>2014-01-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2014-01-02</td>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "      <td>1700</td>\n",
       "      <td>1.60</td>\n",
       "      <td>2014-01-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014-01-02</td>\n",
       "      <td>2014</td>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "      <td>1800</td>\n",
       "      <td>1.15</td>\n",
       "      <td>2014-01-17</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        DATE  EXP_YEAR  EXP_MONTH TYPE  STRIKE  PRICE   MATURITY\n",
       "0 2014-01-02      2014          1    C    1000   7.95 2014-01-17\n",
       "1 2014-01-02      2014          1    C    1500   3.05 2014-01-17\n",
       "2 2014-01-02      2014          1    C    1600   2.20 2014-01-17\n",
       "3 2014-01-02      2014          1    C    1700   1.60 2014-01-17\n",
       "4 2014-01-02      2014          1    C    1800   1.15 2014-01-17"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vstoxx_options.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false,
    "uuid": "ad2ab7b1-ea0b-4275-90a6-89b9f78f50b0"
   },
   "outputs": [],
   "source": [
    "vstoxx_options['STRIKE'] = vstoxx_options['STRIKE'] / 100."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false,
    "uuid": "a2590862-a144-402c-998f-9161797fb7d2"
   },
   "outputs": [],
   "source": [
    "save = False\n",
    "if save is True:\n",
    "    import warnings\n",
    "    warnings.simplefilter('ignore')\n",
    "    h5 = pd.HDFStore('./source/vstoxx_march_2014.h5',\n",
    "                     complevel=9, complib='blosc')\n",
    "    h5['vstoxx_index'] = vstoxx_index\n",
    "    h5['vstoxx_futures'] = vstoxx_futures\n",
    "    h5['vstoxx_options'] = vstoxx_options\n",
    "    h5.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Model Calibration"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Relevant Market Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false,
    "uuid": "c93f5398-8620-48d1-9c6b-ae0c79653751"
   },
   "outputs": [],
   "source": [
    "pricing_date = dt.datetime(2014, 3, 31)\n",
    "  # last trading day in March 2014\n",
    "maturity = third_fridays[10]\n",
    "  # October maturity\n",
    "initial_value = vstoxx_index['V2TX'][pricing_date]\n",
    "  # VSTOXX on pricing_date\n",
    "forward = vstoxx_futures[(vstoxx_futures.DATE == pricing_date)\n",
    "            & (vstoxx_futures.MATURITY == maturity)]['PRICE'].values[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false,
    "uuid": "bd8f1656-44b5-46fc-ab91-f3d14398c09a"
   },
   "outputs": [],
   "source": [
    "tol = 0.20\n",
    "option_selection = \\\n",
    "    vstoxx_options[(vstoxx_options.DATE == pricing_date)\n",
    "                 & (vstoxx_options.MATURITY == maturity)\n",
    "                 & (vstoxx_options.TYPE == 'C')\n",
    "                 & (vstoxx_options.STRIKE > (1 - tol) * forward)\n",
    "                 & (vstoxx_options.STRIKE < (1 + tol) * forward)]                            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false,
    "uuid": "ca4e9611-eda9-4868-8823-5187695ea02f"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DATE</th>\n",
       "      <th>EXP_YEAR</th>\n",
       "      <th>EXP_MONTH</th>\n",
       "      <th>TYPE</th>\n",
       "      <th>STRIKE</th>\n",
       "      <th>PRICE</th>\n",
       "      <th>MATURITY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>46482</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>17</td>\n",
       "      <td>4.85</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46483</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>18</td>\n",
       "      <td>4.30</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46484</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>19</td>\n",
       "      <td>3.80</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46485</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>20</td>\n",
       "      <td>3.40</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46486</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>21</td>\n",
       "      <td>3.05</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46487</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>22</td>\n",
       "      <td>2.75</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46488</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>23</td>\n",
       "      <td>2.50</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46489</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>24</td>\n",
       "      <td>2.25</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46490</th>\n",
       "      <td>2014-03-31</td>\n",
       "      <td>2014</td>\n",
       "      <td>10</td>\n",
       "      <td>C</td>\n",
       "      <td>25</td>\n",
       "      <td>2.10</td>\n",
       "      <td>2014-10-17</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            DATE  EXP_YEAR  EXP_MONTH TYPE  STRIKE  PRICE   MATURITY\n",
       "46482 2014-03-31      2014         10    C      17   4.85 2014-10-17\n",
       "46483 2014-03-31      2014         10    C      18   4.30 2014-10-17\n",
       "46484 2014-03-31      2014         10    C      19   3.80 2014-10-17\n",
       "46485 2014-03-31      2014         10    C      20   3.40 2014-10-17\n",
       "46486 2014-03-31      2014         10    C      21   3.05 2014-10-17\n",
       "46487 2014-03-31      2014         10    C      22   2.75 2014-10-17\n",
       "46488 2014-03-31      2014         10    C      23   2.50 2014-10-17\n",
       "46489 2014-03-31      2014         10    C      24   2.25 2014-10-17\n",
       "46490 2014-03-31      2014         10    C      25   2.10 2014-10-17"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "option_selection"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Option Modeling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false,
    "uuid": "b2f6b10c-bf01-46f6-958a-e0e6266adbe8"
   },
   "outputs": [],
   "source": [
    "from dxa import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false,
    "uuid": "c191a3e9-286e-4c84-8044-aaf05f88377b"
   },
   "outputs": [],
   "source": [
    "me_vstoxx = market_environment('me_vstoxx', pricing_date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false,
    "uuid": "52879659-97e7-4c0f-a14f-b29bea60b3c8"
   },
   "outputs": [],
   "source": [
    "me_vstoxx.add_constant('initial_value', initial_value)\n",
    "me_vstoxx.add_constant('final_date', maturity)\n",
    "me_vstoxx.add_constant('currency', 'EUR')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false,
    "uuid": "f1862ff5-ef88-4364-beba-502872ac5450"
   },
   "outputs": [],
   "source": [
    "me_vstoxx.add_constant('frequency', 'B')\n",
    "me_vstoxx.add_constant('paths', 10000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false,
    "uuid": "b6c44b38-27b6-4c0e-8713-d4c46e2f46c8"
   },
   "outputs": [],
   "source": [
    "csr = constant_short_rate('csr', 0.01)\n",
    "  # somewhat arbitrarily chosen here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false,
    "uuid": "f0aedd9b-a2c9-4713-a02d-cc5a8959408e"
   },
   "outputs": [],
   "source": [
    "me_vstoxx.add_curve('discount_curve', csr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false,
    "uuid": "11c8a827-c54c-451a-93c3-9f8db6df970c"
   },
   "outputs": [],
   "source": [
    "# parameters to be calibrated later\n",
    "me_vstoxx.add_constant('kappa', 1.0)\n",
    "me_vstoxx.add_constant('theta', 1.2 * initial_value)\n",
    "vol_est =  vstoxx_index['V2TX'].std() \\\n",
    "            * np.sqrt(len(vstoxx_index['V2TX']) / 252.)\n",
    "me_vstoxx.add_constant('volatility', vol_est)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false,
    "uuid": "e48f0a24-715c-417f-91ce-86ad49e837bc"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0384283035169406"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vol_est"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false,
    "uuid": "fd70a940-895e-43a4-a66c-d2c3bcc7c285"
   },
   "outputs": [],
   "source": [
    "vstoxx_model = square_root_diffusion('vstoxx_model', me_vstoxx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false,
    "uuid": "fe6d0c61-4907-4466-98ae-3ca782f83964"
   },
   "outputs": [],
   "source": [
    "me_vstoxx.add_constant('strike', forward)\n",
    "me_vstoxx.add_constant('maturity', maturity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false,
    "uuid": "8e36b826-9439-49f2-b4fa-e35928b8df41"
   },
   "outputs": [],
   "source": [
    "payoff_func = 'np.maximum(maturity_value - strike, 0)'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false,
    "uuid": "d33efcec-e027-4b1a-8fa1-c13696779de3"
   },
   "outputs": [],
   "source": [
    "vstoxx_eur_call = valuation_mcs_european('vstoxx_eur_call',\n",
    "                        vstoxx_model, me_vstoxx, payoff_func)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false,
    "uuid": "cedcee4e-1135-4b38-9381-d74b306de63e"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.349653"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vstoxx_eur_call.present_value()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false,
    "uuid": "a4a9ab6f-0810-403f-b172-d08deb80c582"
   },
   "outputs": [],
   "source": [
    "option_models = {}\n",
    "for option in option_selection.index:\n",
    "    strike = option_selection['STRIKE'].ix[option]\n",
    "    me_vstoxx.add_constant('strike', strike)\n",
    "    option_models[option] = \\\n",
    "                        valuation_mcs_european(\n",
    "                                'eur_call_%d' % strike,\n",
    "                                vstoxx_model,\n",
    "                                me_vstoxx,\n",
    "                                payoff_func)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false,
    "uuid": "89ec1029-091b-4ab1-8d60-b7a604c02f69"
   },
   "outputs": [],
   "source": [
    "def calculate_model_values(p0):\n",
    "    ''' Returns all relevant option values.\n",
    "    \n",
    "    Parameters\n",
    "    ===========\n",
    "    p0 : tuple/list\n",
    "        tuple of kappa, theta, volatility\n",
    "    \n",
    "    Returns\n",
    "    =======\n",
    "    model_values : dict\n",
    "        dictionary with model values\n",
    "    '''\n",
    "    kappa, theta, volatility = p0\n",
    "    vstoxx_model.update(kappa=kappa,\n",
    "                        theta=theta,\n",
    "                        volatility=volatility)\n",
    "    model_values = {}\n",
    "    for option in option_models:\n",
    "       model_values[option] = \\\n",
    "         option_models[option].present_value(fixed_seed=True)\n",
    "    return model_values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false,
    "uuid": "d16e0a95-8543-4b08-b056-3d4f83d05e51"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{46482: 3.206401,\n",
       " 46483: 2.412354,\n",
       " 46484: 1.731028,\n",
       " 46485: 1.178823,\n",
       " 46486: 0.760421,\n",
       " 46487: 0.46249,\n",
       " 46488: 0.263662,\n",
       " 46489: 0.142177,\n",
       " 46490: 0.07219}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calculate_model_values((0.5, 27.5, vol_est))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Calibration Procedure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false,
    "uuid": "6d94c077-ebf9-46e3-8185-d4c80d12116d"
   },
   "outputs": [],
   "source": [
    "i = 0\n",
    "def mean_squared_error(p0):\n",
    "    ''' Returns the mean-squared error given\n",
    "    the model and market values.\n",
    "    \n",
    "    Parameters\n",
    "    ===========\n",
    "    p0 : tuple/list\n",
    "        tuple of kappa, theta, volatility\n",
    "    \n",
    "    Returns\n",
    "    =======\n",
    "    MSE : float\n",
    "        mean-squared error\n",
    "    '''\n",
    "    global i\n",
    "    model_values = np.array(calculate_model_values(p0).values())\n",
    "    market_values = option_selection['PRICE'].values\n",
    "    option_diffs = model_values - market_values\n",
    "    MSE = np.sum(option_diffs ** 2) / len(option_diffs)\n",
    "      # vectorized MSE calculation\n",
    "    if i % 20 == 0:\n",
    "        if i == 0:\n",
    "            print '%4s  %6s  %6s  %6s --> %6s' % \\\n",
    "                 ('i', 'kappa', 'theta', 'vola', 'MSE')\n",
    "        print '%4d  %6.3f  %6.3f  %6.3f --> %6.3f' % \\\n",
    "                (i, p0[0], p0[1], p0[2], MSE)\n",
    "    i += 1\n",
    "    return MSE        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false,
    "uuid": "489f4f60-5237-4eff-be12-19abc6583ecb"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   i   kappa   theta    vola -->    MSE\n",
      "   0   0.500  27.500   1.038 -->  4.390\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "4.3899900376937779"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_squared_error((0.5, 27.5, vol_est))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false,
    "uuid": "d4d06a9e-929b-4a02-95c1-433529015988"
   },
   "outputs": [],
   "source": [
    "import scipy.optimize as spo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false,
    "uuid": "15b93990-3228-4330-b5df-10915827ebcc"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   i   kappa   theta    vola -->    MSE\n",
      "   0   0.500  15.000   0.500 --> 10.393\n",
      "  20   0.500  30.000   1.500 -->  2.071\n",
      "  40   1.000  25.000   3.500 -->  0.180\n",
      "  60   1.500  20.000   5.500 -->  0.718\n",
      "  80   2.000  20.000   1.500 -->  5.501\n",
      " 100   2.500  15.000   3.500 -->  5.571\n",
      " 120   2.500  30.000   5.500 --> 22.992\n",
      " 140   3.000  30.000   1.500 --> 14.493\n",
      "CPU times: user 11.9 s, sys: 581 ms, total: 12.5 s\n",
      "Wall time: 12.5 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "i = 0\n",
    "opt_global = spo.brute(mean_squared_error,\n",
    "                ((0.5, 3.01, 0.5),  # range for kappa\n",
    "                 (15., 30.1, 5.),  # range for theta\n",
    "                 (0.5, 5.51, 1)),  # range for volatility\n",
    "                 finish=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false,
    "uuid": "359c3f5f-4f47-4e53-a916-85d3c745ed1b"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   i   kappa   theta    vola -->    MSE\n",
      "   0   1.500  20.000   4.500 -->  0.008\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.0076468730485555626"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i = 0\n",
    "mean_squared_error(opt_global)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false,
    "uuid": "9fd46baf-28af-4276-a1c1-b3e521550cdd"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   i   kappa   theta    vola -->    MSE\n",
      "   0   1.500  20.000   4.500 -->  0.008\n",
      "  20   1.510  19.235   4.776 -->  0.008\n",
      "  40   1.563  18.926   4.844 -->  0.005\n",
      "  60   1.555  18.957   4.828 -->  0.005\n",
      "  80   1.556  18.947   4.832 -->  0.005\n",
      " 100   1.556  18.948   4.831 -->  0.005\n",
      " 120   1.556  18.948   4.831 -->  0.005\n",
      "Optimization terminated successfully.\n",
      "         Current function value: 0.004654\n",
      "         Iterations: 64\n",
      "         Function evaluations: 138\n",
      "CPU times: user 11.3 s, sys: 553 ms, total: 11.9 s\n",
      "Wall time: 11.9 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "i = 0\n",
    "opt_local = spo.fmin(mean_squared_error, opt_global,\n",
    "                     xtol=0.00001, ftol=0.00001,\n",
    "                     maxiter=100, maxfun=350)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false,
    "uuid": "d7c22ea7-b3dd-4408-9ef2-3a986354ba26"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   i   kappa   theta    vola -->    MSE\n",
      "   0   1.556  18.948   4.831 -->  0.005\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.0046542736439999875"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i = 0\n",
    "mean_squared_error(opt_local)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false,
    "uuid": "70b888ee-8d31-46b2-86be-ad95dedd347a"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{46482: 4.746597,\n",
       " 46483: 4.286923,\n",
       " 46484: 3.863346,\n",
       " 46485: 3.474144,\n",
       " 46486: 3.119211,\n",
       " 46487: 2.793906,\n",
       " 46488: 2.494882,\n",
       " 46489: 2.224775,\n",
       " 46490: 1.98111}"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calculate_model_values(opt_local)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false,
    "uuid": "d6cf96da-5139-435e-8ed9-6be593fa7a15"
   },
   "outputs": [],
   "source": [
    "pd.options.mode.chained_assignment = None\n",
    "option_selection['MODEL'] = \\\n",
    "        np.array(calculate_model_values(opt_local).values())\n",
    "option_selection['ERRORS'] = \\\n",
    "        option_selection['MODEL'] - option_selection['PRICE']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false,
    "uuid": "716cd81a-0e06-405c-ade7-7fa407ce19cb"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MODEL</th>\n",
       "      <th>PRICE</th>\n",
       "      <th>ERRORS</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>46482</th>\n",
       "      <td>4.746597</td>\n",
       "      <td>4.85</td>\n",
       "      <td>-0.103403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46483</th>\n",
       "      <td>4.286923</td>\n",
       "      <td>4.30</td>\n",
       "      <td>-0.013077</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46484</th>\n",
       "      <td>3.863346</td>\n",
       "      <td>3.80</td>\n",
       "      <td>0.063346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46485</th>\n",
       "      <td>3.474144</td>\n",
       "      <td>3.40</td>\n",
       "      <td>0.074144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46486</th>\n",
       "      <td>3.119211</td>\n",
       "      <td>3.05</td>\n",
       "      <td>0.069211</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46487</th>\n",
       "      <td>2.793906</td>\n",
       "      <td>2.75</td>\n",
       "      <td>0.043906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46488</th>\n",
       "      <td>2.494882</td>\n",
       "      <td>2.50</td>\n",
       "      <td>-0.005118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46489</th>\n",
       "      <td>2.224775</td>\n",
       "      <td>2.25</td>\n",
       "      <td>-0.025225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46490</th>\n",
       "      <td>1.981110</td>\n",
       "      <td>2.10</td>\n",
       "      <td>-0.118890</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          MODEL  PRICE    ERRORS\n",
       "46482  4.746597   4.85 -0.103403\n",
       "46483  4.286923   4.30 -0.013077\n",
       "46484  3.863346   3.80  0.063346\n",
       "46485  3.474144   3.40  0.074144\n",
       "46486  3.119211   3.05  0.069211\n",
       "46487  2.793906   2.75  0.043906\n",
       "46488  2.494882   2.50 -0.005118\n",
       "46489  2.224775   2.25 -0.025225\n",
       "46490  1.981110   2.10 -0.118890"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "option_selection[['MODEL', 'PRICE', 'ERRORS']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false,
    "uuid": "91c24e54-e18a-4cfe-88b2-82ef82947b9c"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.002"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "round(option_selection['ERRORS'].mean(), 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "collapsed": false,
    "uuid": "9d2912c2-9ab3-4423-95d5-984df6f9f31e"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x7ff23c113c10>"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgIAAAHuCAYAAADtK2SoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl8VPX1//HXASSoIAFFZJNotOJKcKGgInHBgFFrte4b\nliq1LUtb+6uyVNxq9astoFbF3baKVdEqAQSVgLUVF0CtgAo1Cqi4QllkP78/7iQkYRImy525M/N+\nPh73wdw7986cHMfJyf2c+7nm7oiIiEh2apLqAERERCR1VAiIiIhkMRUCIiIiWUyFgIiISBZTISAi\nIpLFVAiIiIhkscgWAmZWZmbvmNk8M3u9hn3Gm9mHZva2mfVIdowiIiLprlmqA6iFA4Xu/k28J83s\nFGA/d9/fzL4P3A30SmaAIiIi6S6yZwRirJbnTgceAXD3OUCumbVPSlQiIiIZIsqFgAMvmtmbZnZ5\nnOc7AUsrrS8DOiclMhERkQwR5aGBY9z9MzNrB8wws0Xu/kq1faqfMagyX7KZaf5kERHJKu5e29n0\n7UT2jIC7fxb790vgGaBntV2WA10qrXeObav+OlpCXK699tqUx5ANi/KsHGfCohyHv9RHJAsBM9vF\nzFrFHu8KnAy8W22354BLYvv0Ala6+4qkBiqUlZWlOoSsoDyHTzkOn3IcTVEdGmgPPGNmEMT4N3ef\nbmaDAdz9XnefYmanmNliYC1wWerCFRERSU+RLATc/SOgIM72e6ut/yJpQUlcAwcOTHUIWUF5Dp9y\nHD7lOJqsvmMK6cDMPJN/PhERkcrMDM+UZkFJD6WlpakOISsoz+FLlxybmRYtmNXpd32tIjk0ICIi\nNdOZTmnMQkBDAxHy7LNw7LGwxx6pjkREosrMVAhIjZ+D2HYNDaSrOXOgRw946aVURyIiItlChUCE\n3HwzPPggXHop/L//Bxs3pjqiHUuXcdV0pzyHTzmWbKVCIGL69YP58+H996FXL1i0KNURiYhIJlOP\nQETMLilh+vjxNNuwgc05OfQbMpRFy4sZNQpuugkuvxwasTdERNJUNvcIDBw4kC5dunDDDTekOpSU\na8weAV01EAGzS0p4YdgwblqypGLbyCVLKBoHs2cXc8EFMHUq3H8/7L57CgMVEUmh+l42l8oCYsyY\nMSxZsoS//OUvSX/vRGloIAKmjx9fpQgAuGnJEmbccQcHHgivvQb5+VBQEL1GQo2rJofyHD7lONq2\nbNkC6NLJMKgQiIBmGzbE3d50/XoAcnLgttvSr5FQRLJLXl4et912G4cddhitWrVi0KBBrFixggED\nBtC6dWv69evHypUrK/Y/++yz6dChA7m5ufTt25cFCxZUPDdw4ECuvPJKTjnlFFq2bLldobZ69WqO\nP/54hg8fDsCiRYvo168fu+++O926dePJJ58EYMKECTz22GPceuuttGrVih/84AdxY58xYwbdunUj\nNzeXIUOG0LdvXx544AEg+Kv+4osvrti3rKyMJk2asHXrVgA+/fRTTj/9dHbffXf2339/7r//fgCm\nTZvGzTffzBNPPEGrVq3o0aMHAKtWrWLQoEF07NiRzp07M3r06IrXWrx4MX379iU3N5d27dpx3nnn\n1fu/R6JUCETA5pycuNu3tGhRZT2KjYSFhYWpDiErKM/hU44bzsyYNGkSL730Eu+//z6TJ09mwIAB\n/OEPf+CLL75g69atjB8/vmL/4uJiFi9ezJdffsnhhx/OhRdeWOX1Hn/8cUaPHs2aNWs49thjK97j\n66+/5sQTT6RPnz6MHTuWtWvX0q9fPy666CK+/PJLJk6cyM9+9jMWLlzIFVdcwYUXXshvf/tbVq9e\nzT/+8Y/t4v7qq68466yz+P3vf8/XX39Nfn4+//rXvyqGIXY0HHHeeeex995789lnn/HUU08xYsQI\nZs6cSf/+/RkxYgTnnXceq1evZt68eUBQ5DRv3pwlS5Ywb948pk+fXlE8jB49mv79+7Ny5UqWL1/O\n0KFD6/8fJEEqBCLg5KFDGZmfX2XbiPx8+g0Zst2+e+wRTDw0eDD06QMTJoDOlIlIObPGWepryJAh\ntGvXjo4dO9KnTx969+5N9+7dycnJ4Yc//GHFL0MIfiHuuuuu7LTTTlx77bW8/fbbrF69uuL5M844\ng969ewOQE/uDafny5RQWFnLuuedy/fXXAzB58mT22WcfLr30Upo0aUJBQQFnnnlmxVkBd691SGHK\nlCkccsghnHnmmTRt2pThw4ez1157VTxf27FLly7lX//6F7fccgvNmzene/fu/OQnP+HRRx+N+94r\nVqxg6tSp/OlPf2LnnXemXbt2DB8+nIkTJwLQvHlzysrKWL58Oc2bN+foo49OLPENoEIgAo4rLqZo\n3DhGFxUxpm9fRhcV0X/cOI4rLo67v1lQCMyeDXffDWeeCV9/neSgYzSumhzKc/gyJcfujbPUV/v2\n7Sse77zzzlXWW7RowZo1a4BgzP/qq69mv/32o3Xr1uyzzz5A8Nc5BH+Fd+nSpdrP5pSUlLB+/XoG\nDx5csf3jjz9mzpw5tGnTpmJ57LHHWLFiRcVr1ebTTz+lc+fOVbZVf+/ajm3bti277rprxba9996b\n5cuXx93/448/ZtOmTXTo0KEi1p/+9Kd8+eWXANx66624Oz179uSQQw7hoYceSiiOhtBVAxFxXHFx\njb/4a1LeSDhyZNBI+PDDcOKJ4cQnIlIfNf01/dhjj/Hcc8/x0ksv0bVrV1auXEnbtm1r/evbzLj8\n8sv59ttvOeWUU5g2bRq77LILe++9N3379mX69Ok1Hlebjh07VhkycHeWLl1asd6yZUvWrVtXsf75\n559XOfabb75hzZo1tGzZEoBPPvmkorCo/t5dunQhJyeHr7/+miZNtv9bvH379kyYMAGAV199lZNO\nOom+ffuy77771vozNITOCKS5VDcSalw1OZTn8CnHybVmzRpycnJo27Yta9euZcSIEVWej1cQlG+7\n8847OeCAAzjttNNYv349xcXFfPDBB/z1r39l06ZNbNq0iTfeeINFsUaq9u3b89///rfGWIqLi3nv\nvfd45pln2Lx5M+PHj6/yy76goIDZs2ezdOlSVq1axc0331zxXJcuXTj66KO55ppr2LBhA++88w4P\n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OOef4mjVr4sZR\n3SeffOJNmjTxU089tcr22bNne7du3bxly5bep08f/93vfud9+vSpeL5JkyYVzYJfffWVn3zyyd6q\nVSs/9thjfcyYMVX2ff/99724uNjbtWvnu+++u5944on+9ttv+8aNG71///7epk0b32233bxnz57+\n6quvJpzjcjV9DqhHs2DkphhuTJpiOByjioq4cfr07baPLirihmnTUhCRSPbQFMMCGT7FsERf5e7i\n0krbl7yzntWrkx5OVkjn8et0oRxLtlIhIHVWU3fxuiYtOOQQmDo1yQGJiEi9aWhA6qx8BrKbliyp\n2DYiP5/+48axqUUxl18Oxx4Lf/qTpigWaWwaGhBo3KEBFQJSL7NLSphxxx00Xb+eLS1a0G/IkIru\n4rVrYdQomDgRxo2Ds88OLkEUkYZTISCgQiBhKgTCV9s93F97DQYNgv33hz//GTp2TG5smaS2PEvj\nSJccqxAQULOgpIlevWDuXOjePbiB0QMPaFZCEZGo0RkBSYp33gnODuy2W3B74333TXVEIunJNM4m\nMRoaSIAKgWjZvBnGjoU//CHoIRgyBFI9oZaISCbR0IAkXV2uvW7WDK66KugdePZZOOYYeO+98GLL\nJLrGPXzKcfiU42hSISBJt99+8PLLcNllUFgI118PGzemOioRkeykoQFJqWXL4Kc/hU8+CZoJK91y\nXERE6khDA5J2OneG55+Ha66B006D3/wG1q1LdVQiItkjsoWAmTU1s3lm9nwNz483sw/N7G0z65Hs\n+CTQGGN+ZnD++fDuu7B8ORx2GGgosSqNrYZPOQ6fchxNkS0EgGHAAmC7c/tmdgqwn7vvD1wB1HzT\naEkb7drBY48FUxNffDEMHgyrVqU6KhGRzBbJHgEz6ww8DNwE/MrdT6v2/D3ATHd/Ira+COjr7iuq\n7acegTS1ahX89rdQUgJ33w2nnprqiEREoi+TegT+BPwG2FrD852ApZXWlwGdww5Kkqd1a7jnHnj0\nURg+HC64AL78MtVRiYhknmapDqA6MzsV+MLd55lZYW27VluP+6f/wIEDycvLAyA3N5eCgoKK+cTL\nx6u0Xv/1+fPnM3z48NBe3wzeeae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gEREZEspkJA\nREQki6kQEBERyWIqBERERLKYCgEREZEspkJAREQki6kQEBERyWIqBERERLKYCgEREZEspkJAREQk\ni6kQEBERyWIqBERERLKYCgEREZEspkJAREQki6kQEBERyWIqBERERLKYCgEREZEspkJAREQki6kQ\nEBERyWIqBERERLKYCgEREZEspkJAREQki6kQEBERyWIqBERERLKYCgEREZEspkJAREQki6kQEBER\nyWIqBERERLKYCgEREZEspkJAREQki6W0EDCz/ma2yMw+NLPfxnm+m5n928zWm9mv63KsiIiI7Ji5\ne2re2Kwp8D5wErAceAM4390XVtqnHdAVOAP41t1vT/RYERER2bFUnhHoCSx29zJ33wRMBH5QeQd3\n/9Ld3wQ21fVYERER2bFUFgKdgKWV1pfFtoV9rIiIiMQ0S+F7N2RMIqFjzSw14x4iIiIp4u5Wl/1T\neUZgOdCl0noXgr/sG/VYd9cS4nLttdemPIZsWJRn5TgTFuU4/KU+UlkIvAnsb2Z5ZtYcOBd4roZ9\nq1c3dTlWQlRWVpbqELKC8hw+5Th8ynE0pWxowN03m9kvgBeApsAD7r7QzAbHnr/XzPYiuCJgN2Cr\nmQ0DDnL3NfGOTc1PIiIikr5SdvlgMpiZZ/LPFwWlpaUUFhamOoyMpzyHTzkOn3IcPjPD69gjoEJA\nREQkQ9SnENAUw9IgpaWlqQ4hKyjP4VOOw6ccR5MKARERkSymoQEREZEMoaEBERERqRMVAtIgGvNL\nDuU5fMpx+JTjaFIhICIiksXUIyAiIpIh1CMgIiIidaJCQBpEY37JoTyHTzkOn3IcTSoEREREsph6\nBERERDKEegRERESkTlQISINozC85lOfwKcfhU46jSYWAiIhIFlOPgIiISIaoT49As7CCEZG6M6vT\n/7+o0BWRhtLQgDSIxvzC4HGWmXG2SWPSZzl8ynE0qRAQERHJYuoREImQYGgg0c+saWhARKpQj4CI\nJJ36GkTSm4YGpEE05pcspakOYAfi9TXEW6JLn+XwKcfRpEJAREQki6lHQCRC0rFHIB1jFslUuteA\niIiI1IkKAWmQKI/5mVmdl+gqT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H2xiiGOfZ0pBCRJ0vC6PjUgSZJmYCEgSdIEsxCQJGmCWQhIkjTBLAQkSZpgFgKS\nJE0wCwFJs5LkG0l2muH5FUkObe5vGrSdpPFiHwFJs9K0hD1yug5lSd7Wd+U+krxaVbsuaICS5sQR\nAUlbSbJLkl8kWZNkXZKL6F1C9r4kq5ptNiW5PMka4OPNVc6OmLKfvZL8LsnxSfZOcmuSh5vb0c02\ny5M81tz+2FxARdIC6frVByXNzXHAhqo6ESDJbsCpwKf72sHuDDxUVd9stnnL8GJzIZk7gQuralWS\nm4Arq+qBJAcA9wAfAs6l15r6wSQ7A/9ZgPcnqWEhIGk6jwOXJ7kY+HlV/bb/UsiN/9K76tl0dqTX\n7/zMqrq/eeyzwAf79rNrkl2AB4Ark9wI3FZVG7bj+5C0DU4NSNpKVf0ZWEbvolLfb6YGpnqtBi8y\negP4A72RhS0CfLSqljW3/avqX1V1CXA6sBPwQJJDtt87kbQtFgKStpJkX3oH+huBy+kVBa8Au81y\nFwWcBhya5LzmsXuBs/t+x+HNvwdV1ZNVdSnwCGAhIC0gpwYkTecw4LIkm+ldxvQM4GjgniQbquoz\nvHnZ0+lUVVWSLwN3JnmFXhFwVZK19L57fg2cCZyT5BhgM/AEcPegnUra/jx9UJKkCebUgCRJE8xC\nQJKkCWYhIEnSBLMQkCRpglkISJI0wSwEJEmaYBYCkiRNsP8BdlyFz/YsPpQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7ff24406f450>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "fix, (ax1, ax2) = plt.subplots(2, sharex=True, figsize=(8, 8))\n",
    "strikes = option_selection['STRIKE'].values\n",
    "ax1.plot(strikes, option_selection['PRICE'], label='market quotes')\n",
    "ax1.plot(strikes, option_selection['MODEL'], 'ro', label='model values')\n",
    "ax1.set_ylabel('option values')\n",
    "ax1.grid(True)\n",
    "ax1.legend(loc=0)\n",
    "wi = 0.25\n",
    "ax2.bar(strikes - wi / 2., option_selection['ERRORS'],\n",
    "        label='market quotes', width=wi)\n",
    "ax2.grid(True)\n",
    "ax2.set_ylabel('differences')\n",
    "ax2.set_xlabel('strikes')\n",
    "# tag: vstoxx_calibration\n",
    "# title: Calibrated model values for VSTOXX call options vs. market quotes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## American Options on the VSTOXX"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Modeling Option Positions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false,
    "uuid": "40decf0f-1908-48e8-b5c3-0fa5b667575c"
   },
   "outputs": [],
   "source": [
    "me_vstoxx = market_environment('me_vstoxx', pricing_date)\n",
    "me_vstoxx.add_constant('initial_value', initial_value)\n",
    "me_vstoxx.add_constant('final_date', pricing_date)\n",
    "me_vstoxx.add_constant('currency', 'NONE')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false,
    "uuid": "88c93f7b-7944-4724-8b7d-a8f9d231d926"
   },
   "outputs": [],
   "source": [
    "# adding optimal parameters to environment\n",
    "me_vstoxx.add_constant('kappa', opt_local[0])\n",
    "me_vstoxx.add_constant('theta', opt_local[1])\n",
    "me_vstoxx.add_constant('volatility', opt_local[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false,
    "uuid": "8d92c037-79db-4663-9ad4-863dc720d160"
   },
   "outputs": [],
   "source": [
    "me_vstoxx.add_constant('model', 'srd')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false,
    "uuid": "ee26163e-cfc2-4bd4-99ef-d9d877dc9592"
   },
   "outputs": [],
   "source": [
    "payoff_func = 'np.maximum(strike - instrument_values, 0)'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false,
    "uuid": "f4882acb-2157-4073-b2e7-b9c79a428a2c"
   },
   "outputs": [],
   "source": [
    "shared = market_environment('share', pricing_date)\n",
    "shared.add_constant('maturity', maturity)\n",
    "shared.add_constant('currency', 'EUR')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": false,
    "uuid": "e48619d3-c12d-4387-bc0d-51dccd00d19e"
   },
   "outputs": [],
   "source": [
    "option_positions = {}\n",
    "  # dictionary for option positions\n",
    "option_environments = {}\n",
    "  # dictionary for option environments\n",
    "for option in option_selection.index:\n",
    "    option_environments[option] = \\\n",
    "        market_environment('am_put_%d' % option, pricing_date)\n",
    "        # define new option environment, one for each option\n",
    "    strike = option_selection['STRIKE'].ix[option]\n",
    "      # pick the relevant strike\n",
    "    option_environments[option].add_constant('strike', strike)\n",
    "      # add it to the environment\n",
    "    option_environments[option].add_environment(shared)\n",
    "      # add the shared data\n",
    "    option_positions['am_put_%d' % strike] = \\\n",
    "                    derivatives_position(\n",
    "                        'am_put_%d' % strike,\n",
    "                        quantity=100.,\n",
    "                        underlying='vstoxx_model',\n",
    "                        mar_env=option_environments[option],\n",
    "                        otype='American',\n",
    "                        payoff_func=payoff_func)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The Options Portfolio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false,
    "uuid": "f885f822-7d78-4841-99c5-f30f1bf23ebb"
   },
   "outputs": [],
   "source": [
    "val_env = market_environment('val_env', pricing_date)\n",
    "val_env.add_constant('starting_date', pricing_date)\n",
    "val_env.add_constant('final_date', pricing_date)\n",
    "  # temporary value, is updated during valuation\n",
    "val_env.add_curve('discount_curve', csr)\n",
    "val_env.add_constant('frequency', 'B')\n",
    "val_env.add_constant('paths', 25000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": false,
    "uuid": "d9a3a473-3cfb-49ab-be94-848349683a9a"
   },
   "outputs": [],
   "source": [
    "underlyings = {'vstoxx_model' : me_vstoxx}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false,
    "uuid": "590ae8ed-39b9-42a3-84f2-35b2b400d8b8"
   },
   "outputs": [],
   "source": [
    "portfolio = derivatives_portfolio('portfolio', option_positions,\n",
    "                                  val_env, underlyings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": false,
    "uuid": "11539da8-35b0-4daf-94ee-52aae7d9fca8"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 24.2 s, sys: 396 ms, total: 24.6 s\n",
      "Wall time: 24.6 s\n"
     ]
    }
   ],
   "source": [
    "%time results = portfolio.get_statistics(fixed_seed=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": false,
    "uuid": "883fa311-3410-4572-a8d1-a526e2914f69"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>quant.</th>\n",
       "      <th>value</th>\n",
       "      <th>curr.</th>\n",
       "      <th>pos_value</th>\n",
       "      <th>pos_delta</th>\n",
       "      <th>pos_vega</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>am_put_17</td>\n",
       "      <td>100</td>\n",
       "      <td>4.575197</td>\n",
       "      <td>EUR</td>\n",
       "      <td>457.5197</td>\n",
       "      <td>-24.85</td>\n",
       "      <td>102.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>am_put_18</td>\n",
       "      <td>100</td>\n",
       "      <td>5.203648</td>\n",
       "      <td>EUR</td>\n",
       "      <td>520.3648</td>\n",
       "      <td>-30.62</td>\n",
       "      <td>107.93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>am_put_19</td>\n",
       "      <td>100</td>\n",
       "      <td>5.872686</td>\n",
       "      <td>EUR</td>\n",
       "      <td>587.2686</td>\n",
       "      <td>-33.31</td>\n",
       "      <td>107.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>am_put_20</td>\n",
       "      <td>100</td>\n",
       "      <td>6.578714</td>\n",
       "      <td>EUR</td>\n",
       "      <td>657.8714</td>\n",
       "      <td>-34.82</td>\n",
       "      <td>110.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>am_put_21</td>\n",
       "      <td>100</td>\n",
       "      <td>7.320523</td>\n",
       "      <td>EUR</td>\n",
       "      <td>732.0523</td>\n",
       "      <td>-39.46</td>\n",
       "      <td>105.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>am_put_22</td>\n",
       "      <td>100</td>\n",
       "      <td>8.081625</td>\n",
       "      <td>EUR</td>\n",
       "      <td>808.1625</td>\n",
       "      <td>-40.61</td>\n",
       "      <td>102.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>am_put_23</td>\n",
       "      <td>100</td>\n",
       "      <td>8.871962</td>\n",
       "      <td>EUR</td>\n",
       "      <td>887.1962</td>\n",
       "      <td>-43.26</td>\n",
       "      <td>104.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>am_put_24</td>\n",
       "      <td>100</td>\n",
       "      <td>9.664272</td>\n",
       "      <td>EUR</td>\n",
       "      <td>966.4272</td>\n",
       "      <td>-40.14</td>\n",
       "      <td>101.04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>am_put_25</td>\n",
       "      <td>100</td>\n",
       "      <td>10.475168</td>\n",
       "      <td>EUR</td>\n",
       "      <td>1047.5168</td>\n",
       "      <td>-45.74</td>\n",
       "      <td>102.81</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        name  quant.      value curr.  pos_value  pos_delta  pos_vega\n",
       "8  am_put_17     100   4.575197   EUR   457.5197     -24.85    102.77\n",
       "1  am_put_18     100   5.203648   EUR   520.3648     -30.62    107.93\n",
       "0  am_put_19     100   5.872686   EUR   587.2686     -33.31    107.79\n",
       "2  am_put_20     100   6.578714   EUR   657.8714     -34.82    110.01\n",
       "6  am_put_21     100   7.320523   EUR   732.0523     -39.46    105.20\n",
       "7  am_put_22     100   8.081625   EUR   808.1625     -40.61    102.38\n",
       "3  am_put_23     100   8.871962   EUR   887.1962     -43.26    104.37\n",
       "4  am_put_24     100   9.664272   EUR   966.4272     -40.14    101.04\n",
       "5  am_put_25     100  10.475168   EUR  1047.5168     -45.74    102.81"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results.sort(columns='name')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false,
    "uuid": "8ceae186-64e2-405d-8563-b6349c0f13b2"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pos_value    6664.3795\n",
       "pos_delta    -332.8100\n",
       "pos_vega      944.3000\n",
       "dtype: float64"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results[['pos_value','pos_delta','pos_vega']].sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Conclusions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Further Reading"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"http://hilpisch.com/tpq_logo.png\" alt=\"The Python Quants\" width=\"35%\" align=\"right\" border=\"0\"><br>\n",
    "\n",
    "<a href=\"http://www.pythonquants.com\" target=\"_blank\">www.pythonquants.com</a> | <a href=\"http://twitter.com/dyjh\" target=\"_blank\">@dyjh</a>\n",
    "\n",
    "<a href=\"mailto:analytics@pythonquants.com\">analytics@pythonquants.com</a>\n",
    "\n",
    "**Python Quant Platform** |\n",
    "<a href=\"http://oreilly.quant-platform.com\">http://oreilly.quant-platform.com</a>\n",
    "\n",
    "**Derivatives Analytics with Python** |\n",
    "<a href=\"http://www.derivatives-analytics-with-python.com\" target=\"_blank\">Derivatives Analytics @ Wiley Finance</a>\n",
    "\n",
    "**Python for Finance** |\n",
    "<a href=\"http://shop.oreilly.com/product/0636920032441.do\" target=\"_blank\">Python for Finance @ O'Reilly</a>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python2",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
